package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.domain.ZhwyChargedata;
import com.ruoyi.domain.ZhwyChargeitem;
import com.ruoyi.domain.ZhwyShops;
import com.ruoyi.mapper.ZhwyChargeitemMapper;
import com.ruoyi.mapper.ZhwyShopsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.ZhwyMeterreadingdataMapper;
import com.ruoyi.domain.ZhwyMeterreadingdata;
import com.ruoyi.service.IZhwyMeterreadingdataService;

/**
 * 抄表数据表Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-07
 */
@Service
public class ZhwyMeterreadingdataServiceImpl implements IZhwyMeterreadingdataService 
{
    @Autowired
    private ZhwyMeterreadingdataMapper zhwyMeterreadingdataMapper;

    @Autowired
    private ZhwyChargeitemMapper zhwyChargeitemMapper;

    @Autowired
    private ZhwyShopsMapper zhwyShopsMapper;


    /**
     * 查询抄表数据表
     * 
     * @param id 抄表数据表主键
     * @return 抄表数据表
     */
    @Override
    public ZhwyMeterreadingdata selectZhwyMeterreadingdataById(Long id)
    {
        return zhwyMeterreadingdataMapper.selectZhwyMeterreadingdataById(id);
    }

    /**
     * 查询抄表数据表列表
     * 
     * @param zhwyMeterreadingdata 抄表数据表
     * @return 抄表数据表
     */
    @Override
    public List<ZhwyMeterreadingdata> selectZhwyMeterreadingdataList(ZhwyMeterreadingdata zhwyMeterreadingdata)
    {
        List<ZhwyMeterreadingdata> zhwyMeterreadingdatas = zhwyMeterreadingdataMapper.selectZhwyMeterreadingdataList(zhwyMeterreadingdata);
        for(ZhwyMeterreadingdata zh:zhwyMeterreadingdatas){
            //获取关联收款项目
            ZhwyChargeitem zhwyChargeitem = zhwyChargeitemMapper.selectZhwyChargeitemById(zh.getType());
            ZhwyShops zhwyShops = zhwyShopsMapper.selectZhwyShopsById(zh.getShopsId());
            zh.setChargeitemName(zhwyChargeitem.getName());
            zh.setShopsCode(zhwyShops.getCode());
        }
        return zhwyMeterreadingdatas;
//        return zhwyMeterreadingdataMapper.selectZhwyMeterreadingdataList(zhwyMeterreadingdata);
    }

    /**
     * 新增抄表数据表
     * 
     * @param zhwyMeterreadingdata 抄表数据表
     * @return 结果
     */
    @Override
    public int insertZhwyMeterreadingdata(ZhwyMeterreadingdata zhwyMeterreadingdata)
    {
        return zhwyMeterreadingdataMapper.insertZhwyMeterreadingdata(zhwyMeterreadingdata);
    }

    /**
     * 修改抄表数据表
     * 
     * @param zhwyMeterreadingdata 抄表数据表
     * @return 结果
     */
    @Override
    public int updateZhwyMeterreadingdata(ZhwyMeterreadingdata zhwyMeterreadingdata)
    {
        return zhwyMeterreadingdataMapper.updateZhwyMeterreadingdata(zhwyMeterreadingdata);
    }

    /**
     * 批量删除抄表数据表
     * 
     * @param ids 需要删除的抄表数据表主键
     * @return 结果
     */
    @Override
    public int deleteZhwyMeterreadingdataByIds(Long[] ids)
    {
        return zhwyMeterreadingdataMapper.deleteZhwyMeterreadingdataByIds(ids);
    }

    /**
     * 删除抄表数据表信息
     * 
     * @param id 抄表数据表主键
     * @return 结果
     */
    @Override
    public int deleteZhwyMeterreadingdataById(Long id)
    {
        return zhwyMeterreadingdataMapper.deleteZhwyMeterreadingdataById(id);
    }

    //    批量新增
    @Override
    public int batchInsertZhwyMeterreadingdata(List<ZhwyMeterreadingdata> meterreadingdataList) {

        return zhwyMeterreadingdataMapper.batchInsertZhwyMeterreadingdata(meterreadingdataList);
    }


}
